home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / wwbbs31_source.lha / WWBBS / MessageMaintSrc / messagemaint.c < prev    next >
C/C++ Source or Header  |  1995-03-28  |  3KB  |  140 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <libraries/wwbbs.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. #include <proto/exec.h>
  9. #include <proto/dos.h>
  10. #include <proto/wwbbs.h>
  11.  
  12. #include "messagemaint_rev.h"
  13.  
  14. char *ver=VERSTAG;
  15.  
  16. struct Library *WorldWideBase;
  17.  
  18. void close_all(void);
  19. BOOL GetNextArea(BYTE *,BYTE *);
  20.  
  21. void main()
  22.     {
  23.         if(!(WorldWideBase=OpenLibrary("wwbbs.library",0)))
  24.             close_all();
  25.         {
  26.             struct DateStamp CurrentDate;
  27.             DateStamp(&CurrentDate);
  28.             {
  29.                 BYTE path[256],area[33],groupname[21];
  30.                 ULONG days=0;
  31.                 strcpy(path,"MessageBases");
  32.                 strcpy(area,"");
  33.                 strcpy(groupname,"");
  34.                 while(GetNextArea(path,area))
  35.                     {
  36.                         if(GetConfigTags(CFGTAG_Path,path,CFGTAG_Name,area,MBTAG_Days,&days,MBTAG_Group,groupname,TAG_END))
  37.                             {
  38.                                 if(days)
  39.                                     {
  40.                                         APTR group;
  41.                                         if(group=OpenMessageGroup(path,area,EXCLUSIVE_LOCK))
  42.                                             {
  43.                                                 ULONG count=0;
  44.                                                 ULONG next=0;
  45.                                                 struct DateStamp *ds=NULL;
  46.                                                 while(next=GetNextMessage(group,next))
  47.                                                     {
  48.                                                         if(GetMessageTags(group,MSGTAG_ID,next,MSGTAG_Date,&ds,TAG_END))
  49.                                                             {
  50.                                                                 if(ds->ds_Days+days<CurrentDate.ds_Days)
  51.                                                                     {
  52.                                                                         if(RemMessageTags(group,MSGTAG_ID,next,MSGTAG_DontSave,TRUE,TAG_END))
  53.                                                                             count++;
  54.                                                                     }
  55.                                                             }
  56.                                                     }
  57.                                                 if(count)
  58.                                                     SetMessageTags(group,MSGTAG_ForceSave,TRUE,TAG_END);
  59.                                                 CloseMessageGroup(group);
  60.                                                 if(count)
  61.                                                     {
  62.                                                         char s[64];
  63.                                                         sprintf(s,"`%ld' messages deleted from %s.",count,groupname);
  64.                                                         LogEntry(NULL,"Message Maintenance",s);
  65.                                                     }
  66.                                             }
  67.                                     }
  68.                             }
  69.                     }
  70.             }
  71.         }
  72.         close_all();
  73.     }
  74.  
  75. void close_all()
  76.     {
  77.         if(WorldWideBase) CloseLibrary(WorldWideBase);
  78.         exit(RETURN_OK);
  79.     }
  80.  
  81. BOOL GetNextArea(BYTE *path,BYTE *name)
  82.     {
  83.         BOOL ret=FALSE;
  84.         if(strlen(name))
  85.             {
  86.                 BYTE next[33];
  87.                 strcpy(next,"");
  88.                 GetConfigTags(CFGTAG_Path,path,CFGTAG_Name,name,CFGTAG_GetNext,next,TAG_END);
  89.                 if(strlen(next))
  90.                     {
  91.                         BOOL child=FALSE;
  92.                         GetConfigTags(CFGTAG_Path,path,CFGTAG_Name,next,CFGTAG_Child,&child,TAG_END);
  93.                         if(child)
  94.                             {
  95.                                 AddPart(path,next,255);
  96.                                 strcpy(name,"");
  97.                                 ret=GetNextArea(path,name);
  98.                             }
  99.                         else
  100.                             {
  101.                                 strcpy(name,next);
  102.                                 ret=TRUE;
  103.                             }
  104.                     }
  105.                 else
  106.                     {
  107.                         if(strchr(path,'/'))
  108.                             {
  109.                                 char *p;
  110.                                 strcpy(name,FilePart(path));
  111.                                 p=PathPart(path);
  112.                                 *p=NULL;
  113.                                 ret=GetNextArea(path,name);
  114.                             }
  115.                     }
  116.             }
  117.         else
  118.             {
  119.                 BYTE first[33];
  120.                 strcpy(first,"");
  121.                 GetConfigTags(CFGTAG_Path,path,CFGTAG_GetFirst,first,TAG_END);
  122.                 if(strlen(first))
  123.                     {
  124.                         BOOL child=FALSE;
  125.                         GetConfigTags(CFGTAG_Path,path,CFGTAG_Name,first,CFGTAG_Child,&child,TAG_END);
  126.                         if(child)
  127.                             {
  128.                                 AddPart(path,first,255);
  129.                                 ret=GetNextArea(path,name);
  130.                             }
  131.                         else
  132.                             {
  133.                                 strcpy(name,first);
  134.                                 ret=TRUE;
  135.                             }
  136.                     }
  137.             }
  138.         return(ret);
  139.     }
  140.